﻿using AbstructFactory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Web.Http;
using XF.Meeting.Api.Filters;
using XF.Meeting.Entity.CommonEntity;

namespace XF.Meeting.Api.Controllers
{
   [Meeting]
    public class BaseController : ApiController
    {
        public AbsFactoryTE abs = (AbsFactoryTE)AbsFactory.CreateInterface();
        public LoginUser GetUser(ClaimsIdentity dic)
        {
            var user = new LoginUser();
            foreach (var item in dic.Claims)
            {
                switch (item.Type)
                {
                    case "userName":
                        user.UserName = item.Value;
                        break;
                    case "UserId":
                        user.UserId = Convert.ToInt32(item.Value);
                        break;
                    case "IsAdmin":
                        user.IsAdmin = Convert.ToInt32(item.Value);
                        break;
                    case "role":
                        user.Roles = item.Value;
                        break;
                    case "RegionalId":
                        user.RegionId = item.Value;
                        break;
                    case "OrgId":
                        user.OrgId = item.Value;
                        break;
                
                }
            }
            return user;
        }
    }
}
